package com.pig4cloud.pig.trip.Service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.common.security.util.SecurityUtils;
import com.pig4cloud.pig.trip.Service.TrTripContentService;
import com.pig4cloud.pig.trip.Service.TrTripService;
import com.pig4cloud.pig.trip.api.entity.TrTrip;
import com.pig4cloud.pig.trip.api.entity.TrTripContent;
import com.pig4cloud.pig.trip.mapper.TrTripContentMapper;
import com.pig4cloud.pig.trip.mapper.TrTripMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static cn.hutool.core.date.DateTime.now;

@Service
@AllArgsConstructor
public class TrTripContentServiceImpl extends ServiceImpl<TrTripContentMapper, TrTripContent> implements TrTripContentService {
	@Autowired
	private  TrTripContentMapper trTripContentMapper;

	@Override
	public int insertTripContent(TrTripContent trTripContent) {
		trTripContent.setDelFlag('0');
		//设置创建时间
		trTripContent.setCreateTime(now());
		//设置由谁创建
		trTripContent.setCreateBy(SecurityUtils.getUser().getName());
		//设置由谁更新
		trTripContent.setUpdateBy(SecurityUtils.getUser().getName());

		return trTripContentMapper.insertTripContent(trTripContent);
	}

	@Override
	public int removeByContentId(Long tripContentId) {
		return trTripContentMapper.removeByContentId(tripContentId);
	}

	@Override
	public int updateTripContent(TrTripContent trTripContent) {
		return trTripContentMapper.updateTripContent(trTripContent);
	}
}
